import { Tooltip } from 'antd';
import { removeDateHmsStr, renderTableText, tableSorter } from '@/utils';
import pageStyles from '@/common/pageLayout.less';

import { DictionaryRenderFun } from '../../Acommon';

/** 材料Table表格的配置 */
const materialTableColumnOA = () => {
  const columnConfig: Record<string, any>[] = [
    {
      title: '材料名称',
      dataIndex: 'assetName',
      key: 'assetName',
      width: 110,
      fixed: 'left',
      sorter: (a: any, b: any) => tableSorter(a, b, 'assetName'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '材料分类',
      dataIndex: 'assetClassName',
      key: 'assetClassName',
      width: 110,
      sorter: (a: any, b: any) => tableSorter(a, b, 'assetClassName'),
      render: (text: number) => DictionaryRenderFun({ text, isState: false }),
    },
    {
      title: '规格型号',
      dataIndex: 'paramsInfo',
      key: 'paramsInfo',
      width: 110,
      sorter: (a: any, b: any) => tableSorter(a, b, 'paramsInfo'),
      render: (text: string) => renderTableText(text, true),
    },

    {
      title: '计量单位',
      dataIndex: 'unitOfMeasurementName',
      key: 'unitOfMeasurementName',
      width: 140,
      sorter: (a: any, b: any) => tableSorter(a, b, 'unitOfMeasurementName'),
      render: (text: string) => DictionaryRenderFun({ text, isState: false }),
    },
    {
      title: '单价',
      dataIndex: 'assetValue',
      key: 'assetValue',
      width: 100,
      sorter: (a: any, b: any) => tableSorter(a, b, 'assetValue'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '供应商',
      dataIndex: 'supplier',
      key: 'supplier',
      width: 150,
      // ishidden: (queryType == '2' ? true : false),
      visible: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'supplier'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '材料数量',
      dataIndex: 'residueNum',
      key: 'residueNum',
      visible: true,
      width: 100,
      sorter: (a: any, b: any) => tableSorter(a, b, 'quantityOrArea'),
      render: (text: string, record: any) => {
        return (
          <Tooltip title={text}>
            <div className={pageStyles['over-flow-hidden']}>{text || record?.expectNum + record?.quantityOrArea || '--'}</div>
          </Tooltip>
        );
      },
    },
    {
      title: '总价',
      dataIndex: 'totalValue',
      key: 'totalValue',
      width: 100,
      sorter: (a: any, b: any) => tableSorter(a, b, 'totalValue'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '品牌',
      dataIndex: 'brandType',
      key: 'brandType',
      width: 100,
      sorter: (a: any, b: any) => tableSorter(a, b, 'brandType'),
      render: (text: string) => DictionaryRenderFun({ text, isState: false }),
    },
    {
      title: '取得日期',
      dataIndex: 'enterStoreTime',
      key: 'enterStoreTime',
      width: 150,
      sorter: (a: any, b: any) => tableSorter(a, b, 'enterStoreTime'),
      render: (text: string) => removeDateHmsStr(text) || '--',
    },
  ];

  return columnConfig;
};

export { materialTableColumnOA };
